//
//  MyTopicSectionHeaderView.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/14.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "MyTopicSectionHeaderView.h"

@implementation MyTopicSectionHeaderView



+(CGFloat)calculateHWithModel:(CommonPostModel *)model {
    CGFloat topPading = 5;//距离顶部的距离


    CGFloat xiajiaHeight = 30;//用户信息高度
    //状态（1：待审核，2：审核拒绝，3：审核通过-上架，4：下架）
    switch (model.status) {
        case 1:{
            xiajiaHeight = CGFLOAT_MIN;
        } break;
        case 2:{
            xiajiaHeight = CGFLOAT_MIN;
        } break;
        case 3:{
            xiajiaHeight = CGFLOAT_MIN;
        } break;
        case 4:{
            xiajiaHeight = 30;
        } break;
        default:
            break;
    }

    CGFloat deleteHeight = 30;//用户信息高度
    CGFloat labHeight = 40;//文字高度可计算
        
    CGFloat bottomHeight = 30;//底部
    CGFloat bottomPading = 5;//距离

    return topPading + xiajiaHeight + deleteHeight + labHeight + bottomHeight + bottomPading;    
    
}

- (void)fillWithModel:(CommonPostModel *)model {
    
    if (model.status == 4) {
        self.xiajiaHeight.constant = 30;
    } else {
        self.xiajiaHeight.constant = CGFLOAT_MIN;
    }
    
    switch (model.status) {
        case 1:{
            [self.xiajiaBtn setTitle:@" 待审核" forState:UIControlStateNormal];
        } break;
        case 2:{
            [self.xiajiaBtn setTitle:@" 审核拒绝" forState:UIControlStateNormal];
        } break;
        case 3:{
            [self.xiajiaBtn setTitle:@" 上架" forState:UIControlStateNormal];
        } break;
        case 4:{
            [self.xiajiaBtn setTitle:[NSString stringWithFormat:@" 强制下架：%@",model.reason] forState:UIControlStateNormal];
        } break;
        default:
            break;
    }
    
    self.timeLab.text = [NSString stringWithFormat:@"发布于：%@",model.createTime];
    self.contentLab.text = model.content;
    
    [self.tagBtn setTitle:[NSString stringWithFormat:@" %@",model.themeTitle] forState:UIControlStateNormal];
    
    self.evaThumbLab.text = [NSString stringWithFormat:@"评论%ld·赞%ld",model.replyCount,model.likes];

}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.xiajiaBtn pp_clipCorners:UIRectCornerAllCorners radius:self.xiajiaBtn.frame.size.height/2 border:1 color:UIColorHex(0xFF7200)];
    });
    
}

- (IBAction)delAction:(id)sender {
    if (self.MYTopicSectionHeaderViewBlock) {
        self.MYTopicSectionHeaderViewBlock(MYTopicSectionHeaderActionType_del);
    }
}


@end
